#include <iostream>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <cstring>

using namespace std;

volatile int flag = 0;

void handler(int signum)
{
    cout << "received signal " << signum << endl,
    flag = 1;
}

int main()
{
    signal(2, handler);

    while (!flag);

    cout << "process exit normally" << endl;
    return 0;
}
